package cn.swu.lzr.event;

import com.fasterxml.jackson.databind.ObjectMapper;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;

import java.io.IOException;
import java.io.Writer;
import java.util.List;


public class SearchResults extends HttpServlet {


    public void doGet(HttpServletRequest request, HttpServletResponse response)throws IOException {


        HttpSession session = request.getSession();
        List events = (List) session.getAttribute("SearchType");
        ObjectMapper mapper = new ObjectMapper();
        String json = mapper.writeValueAsString(events);
        response.setContentType("application/json");
        response.setCharacterEncoding("UTF-8");

        try (Writer writer =  response.getWriter()){
            writer.write(json);
        }
    }
}
